package cn.exrick.xboot.modules.your;

import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * Created with IntelliJ IDEA.
 *
 * @Auther: njp
 * @Date: 2020/05/26/17:36
 * @Description:
 */
@Component
@Slf4j
public class SpringbootTimeTest {
    /*@Scheduled(fixedRate = 60000)//每隔一分钟查一次
    public  void timeOut(){
        log.info("springboot计时测试");
    }*/


   public void timeOut(){

       Timer timer = new Timer();
       timer.schedule(new TimerTask() {
           public void run() {
               System.out.println("11232");
           }
       }, 200000 , 1000);
   }


/*   public   void timeOut2(){
       ScheduledExecutorService executorService = new ScheduledThreadPoolExecutor(1,
               new BasicThreadFactory.Builder().namingPattern("example-schedule-pool-%d").daemon(true).build());
       executorService.scheduleAtFixedRate(new Runnable() {
           @Override
           public void run() {
               //do something
           }
       },10,10*, TimeUnit.SECONDS);

   }*/

}
